package com.TTBook.impl.image.daoImpl;

import com.TTBook.core.image.dao.BookImgRelDAO;
import com.TTBook.core.image.model.BookImgRel;
import com.TTBook.core.image.model.BookImgRelCriteria;
import java.util.List;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

public class BookImgRelDAOImpl extends SqlMapClientDaoSupport implements BookImgRelDAO {

    public BookImgRelDAOImpl() {
        super();
    }

    public int countByCriteria(BookImgRelCriteria criteria) {
        Integer count = (Integer)  getSqlMapClientTemplate().queryForObject("ts_book_img_rel.countByCriteria", criteria);
        return count.intValue();
    }

    public int deleteByCriteria(BookImgRelCriteria criteria) {
        int rows = getSqlMapClientTemplate().delete("ts_book_img_rel.deleteByCriteria", criteria);
        return rows;
    }

    public void insert(BookImgRel record) {
        getSqlMapClientTemplate().insert("ts_book_img_rel.insert", record);
    }

    public void insertSelective(BookImgRel record) {
        getSqlMapClientTemplate().insert("ts_book_img_rel.insertSelective", record);
    }

    public List selectByCriteria(BookImgRelCriteria criteria) {
        List list = getSqlMapClientTemplate().queryForList("ts_book_img_rel.selectByCriteria", criteria);
        return list;
    }

    public int updateByCriteriaSelective(BookImgRel record, BookImgRelCriteria criteria) {
        UpdateByCriteriaParms parms = new UpdateByCriteriaParms(record, criteria);
        int rows = getSqlMapClientTemplate().update("ts_book_img_rel.updateByCriteriaSelective", parms);
        return rows;
    }

    public int updateByCriteria(BookImgRel record, BookImgRelCriteria example) {
        UpdateByCriteriaParms parms = new UpdateByCriteriaParms(record, example);
        int rows = getSqlMapClientTemplate().update("ts_book_img_rel.updateByCriteria", parms);
        return rows;
    }

    private static class UpdateByCriteriaParms extends BookImgRelCriteria {
        private Object record;

        public UpdateByCriteriaParms(Object record, BookImgRelCriteria criteria) {
            super(criteria);
            this.record = record;
        }

        public Object getRecord() {
            return record;
        }
    }
}